# file:: $Name$
# author::  $Author$
# version:: $Revision$
# date:: $Date$
#
# This source code copyright (C) 2006 by Ralph M. Churchill
# All rights reserved.
#
# Released under the terms of the GNU General Public License
# See LICENSE file for additional information.

require 'engine/command'

class Go < Command
    def initialize(executor)
        super(executor,"go","go exit",
              "Leave the current room through exit.")
    end
    def execute(params)
        raise UsageException if params.empty?
        room = self.executor.room
        the_exit = params.join(' ')
        room.portals.each do |portal|
            if go = portal.entries.find{|x| x.named? the_exit and x.start_room==room}
                GameEngine.instance.do_action(
                      Action.new(:attemptenterportal,self.executor,
                                 {:room => go.end_room,:portal => portal}))
            else
                inform("You cannot go that way.")
            end
        end
    end
end
